package angry.courses.servlets;

import java.util.List;

import javax.naming.InitialContext;

import angry.courses.beans.StudentBean;
import angry.courses.beans.Student;
import angry.courses.entities.StudentEntity;

public class StudentDelegate {
	private Student studentBean;
  
	public StudentDelegate() {
		try {
			InitialContext ctx = new InitialContext();
			studentBean = (Student) ctx.lookup("angry.courses.beans.StudentBean");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public boolean validateStudent(String name, String regnr) {
		return studentBean.validateStudent(name, regnr);
	}
	
	public StudentEntity getStudent(String regnr) {
		return studentBean.getStudent(regnr);
	}
	
	public StudentEntity getStudentByName(String name) {
		return studentBean.getStudentByName(name);
	}
	
	public void deleteStudent(StudentEntity student) {
		studentBean.deleteStudent(student);
	}
	
	public List<String> getStudentNames() {
		return studentBean.getStudentNames();
	}
}
